﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CH.TestData.Common;
namespace CH.TestData.Provider
{
    [DataTypeName("整型")]
    public class IntProvider : IDataProvider
    {

        private string columnName;
        private int from;
        private int to;
        public void SetDataSource(FlowLayoutPanel flp)
        {
            TextBox txtColumnName = flp.Controls.Find("txtColumnName", false).First() as TextBox;
            this.columnName = txtColumnName.Text;

            TextBox txtFrom = flp.Controls.Find("txtFrom", true).First() as TextBox;
            this.from = int.Parse(txtFrom.Text);

            TextBox txtTo = flp.Controls.Find("txtTo", true).First() as TextBox;
            this.to = int.Parse(txtTo.Text);
        }
        public void CreateOption(FlowLayoutPanel flp)
        {
            Label lblc = new Label();
            lblc.Text = "从";
            lblc.Width = 30;
            lblc.Margin = new Padding(0, 7, 0, 0);
            flp.Controls.Add(lblc);

            TextBox txtFrom = new TextBox();
            txtFrom.Name = "txtFrom";
            txtFrom.Text = "0";
            txtFrom.Width = 60;
            txtFrom.Margin = new Padding(0, 3, 0, 0);
            flp.Controls.Add(txtFrom);

            Label lbld = new Label();
            lbld.Text = "开始,到";
            lbld.Width = 60;
            lbld.Margin = new Padding(0, 7, 0, 0);
            flp.Controls.Add(lbld);

            TextBox txtTo = new TextBox();
            txtTo.Name = "txtTo";
            txtTo.Text = "100";
            txtTo.Width = 60;
            txtTo.Margin = new Padding(0, 3, 0, 0);
            flp.Controls.Add(txtTo);

            Label lblzf = new Label();
            lblzf.Text = "结束";
            lblzf.Width = 50;
            lblzf.Margin = new Padding(0, 7, 0, 0);
            flp.Controls.Add(lblzf);
        }

        public string GetNextValue()
        {
            return new Random(Guid.NewGuid().GetHashCode()).Next(from, to).ToString();
        }
    }
}
